<template>
	<view class="page" :style="{minHeight: vheight + 'rpx'}">
		<view class="bar_info" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class="title_bar">
				<view class="title_bar_left" @tap.stop="isBack">
					<u-icon size="38" color="#FFF" name="arrow-left"></u-icon>
				</view>
				<view class="title_bar_center">
					我的团队
				</view>
				<view class="title_bar_right"></view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#0E7EFD"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		<block v-else>
			<view class="money_info">
				<view class="user_info">
					<view class="user_info_left">
						<image :src="userInfo.avatar" mode="aspectFill"></image>
					</view>
					<view class="user_info_right">
						<view class="user_info_right_1">
							<text>{{userInfo.nickname}}</text>
							<image :src="userInfo.vip_level_image" mode=""></image>
						</view>
						<view class="user_info_right_2">{{userInfo.mobile}}</view>
					</view>
				</view>
			</view>
			<view class="record">
				<view class="record_list">
					<view class="list_item" v-for="(v, k) in list" :key="k">
						<view class="list_item_left">
							<view class="list_item_left_img">
								<image :src="v.avatar" mode="aspectFill"></image>
							</view>
							<view class="list_item_left_text">
								<view class="list_item_left_text_1">
									<text>{{v.mobile}}</text>
									<text style="margin-left: 10rpx;">{{v.nickname}}</text>
									<image :src="v.vip_level_image" mode="aspectFill"></image>
								</view>
								<view class="list_item_left_text_2">
									{{v.create_time}}
								</view>
							</view>
						</view>
						<view class="list_item_bottom">
							<view class="bottom_item">
								<view class="bottom_item_1">兑换总积分</view>
								<view class="bottom_item_2">{{v.total_score}}</view>
							</view>
							<view class="bottom_item">
								<view class="bottom_item_1">兑收益</view>
								<view class="bottom_item_2">{{v.total_income}}</view>
							</view>
						</view>
					</view>
					<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status"
						:icon-type="iconType" :load-text="loadText" />
				</view>
				<view class="noData_other" v-if="list.length == 0 && !isShow">
					<image src="/static/empty/no.png"></image>
					<view>没有团队成员~</view>
				</view>
			</view>
			
		</block>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				userInfo: {},
				vheight: 0,
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
			}
		},
		onLoad() {
			let _this = this;
			uni.getSystemInfo({
				success(res) {
					_this.vheight = res.windowHeight / (uni.upx2px(10)/10);
				}
			});
		},
		onShow() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getTeam();
			this.getUserInfo();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getTeam();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getTeam();
			}, 500)
		},
		methods: {
			// 获取用户资料  postUserInfo
			getUserInfo() {
				this.$api.post(global.apiUrls.postUserInfo, {
			
				}).then(res => {
					if (res.data.code == 1) {
						this.userInfo = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 我的团队  postMyTeam
			getTeam() {
				this.$api.post(global.apiUrls.postMyTeam, {
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			isBack() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #fff !important;
		background: url('https://asjf.yunyakeji.cn/uploads/mini/2.png') no-repeat;
		background-size: 100% 558rpx !important;
		.bar_info {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			// border-bottom: 1px solid #eee;
			// background: #fff;
			z-index: 10;
			position: fixed;
			top: 0rpx;
		
			.title_bar {
				padding: 0 32rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
		
				.title_bar_left {
					width: 50rpx;
				}
		
				.title_bar_center {
					line-height: 88rpx;
					font-size: 36rpx;
					font-weight: 400;
					color: #fff;
				}
		
				.title_bar_right {
					width: 50rpx;
				}
			}
		}
		.money_info {
			padding: 24rpx 30rpx 0;
			.user_info {
				display: flex;
				padding: 30rpx 0 0;
				margin-bottom: 42rpx;
				.user_info_left {
					width: 62rpx;
					height: 62rpx;
					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}
				.user_info_right {
					width: calc(100% - 62rpx);
					padding: 0 0 0 20rpx;
					transform: translateY(-5rpx);
					.user_info_right_1 {
						font-size: 30rpx;
						color: #fff;
						display: flex;
						align-items: center;
						image {
							width: 106rpx;
							height: 27rpx;
							margin-left: 14rpx;
						}
					}
					.user_info_right_2 {
						font-size: 24rpx;
						color: #fff;
						opacity: 0.6;
						// margin-top: 5rpx;
					}
				}
			}
			.income_view {
				padding: 47rpx 24rpx;
				display: flex;
				background: url(./static/3.png) no-repeat;
				background-size: 100% 100%;
				.income_item {
					width: 50%;
					text-align: center;
					.income_item_1 {
						font-size: 48rpx;
						font-weight: 400;
					}
					.income_item_2 {
						font-size: 26rpx;
						color: #999;
						margin-bottom: 16rpx;
					}
				}
			}
		}
		.record {
			background: #fff;
			border-radius: 50rpx 50rpx 0 0;
			padding: 42rpx 30rpx 30rpx;
			
			.record_list {
				.list_item {
					padding: 32rpx 0;
					// border-bottom: 1rpx solid #eee;
					.list_item_left {
						display: flex;
						.list_item_left_img {
							width: 70rpx;
							height: 70rpx;
							image {
								width: 100%;
								height: 100%;
								border-radius: 50%;
							}
						}
						.list_item_left_text {
							padding-left: 20rpx;
							.list_item_left_text_1 {
								display: flex;
								align-items: center;
								font-size: 32rpx;
								color: #000;
								image {
									width: 110rpx;
									height: 30rpx;
									margin-left: 16rpx;
									transform: translateY(-2rpx);
								}
							}
							.list_item_left_text_2 {
								font-size: 24rpx;
								color: #999;
								margin-top: 12rpx;
							}
						}
					}
					.list_item_bottom {
						background: #F6F8FA;
						border-radius: 10rpx;
						padding: 35rpx 0 32rpx;
						display: flex;
						margin-top: 24rpx;
						.bottom_item {
							// display: flex;
							width: 50%;
							text-align: center;
							.bottom_item_1 {
								color: #999999;
								font-size: 22rpx;
							}
							.bottom_item_2 {
								font-weight: 900;
								font-size: 32rpx;
								margin-top: 8rpx;
							}
						}
					}
				}
			}
		}
	}
</style>